<!-- 设置 -->
<template>
  <div>
    <van-cell title="手机号" :value="mobile" size="large" />
    <van-cell title="修改密码" size="large" is-link @click="$router.push('/modifypwd')" />
    <div class="logoutSty">
      <van-button type="info" @click="logout">退出登录</van-button>
    </div>
  </div>
</template>

<script>
export default {
  data () {
    return {
      mobile: ''
    }
  },
  methods: {
    logout () {
      this.$dialog.confirm({
        title: '退出登录',
        message: '此操作将退出登录, 是否继续?',
        confirmButtonText: '退出登录'
      }).then(() => {
        localStorage.removeItem('token')
        // this.$cookies.remove('token')
        this.$router.replace('/')
      }).catch(() => {
        // on cancel
      });
    },
    gethome () {
      // 从localstorage 获取手机号
      this.mobile = JSON.parse(localStorage.getItem('userData')).mobile;
      // 修改手机号码 中间隐藏
      // this.mobile = this.mobile.substring(0,3)+ '****' + this.mobile.substring(7,11)

    }
  },
  mounted () {
    this.gethome();
  }
}
</script>

<style scoped>
.logoutSty {
  padding: 0rem 0.3rem;
  margin-top: 0.3rem;
  position: absolute;
  bottom: 20px;
  width: 100%;
  box-sizing: border-box;
}
</style>
